import { Button, Cell, DatetimePicker, Field, Image, Popup } from '@antmjs/vantui';
import { View } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { pxTransform } from '@tarojs/taro';
import { FFormCustom } from '@vh-mobile/pro-components';
import type { ColumnsType } from '@vh-mobile/pro-components/lib/f-form-custom/types';
import { toast } from '@vh-mobile/pro-utils';
import { useState } from 'react';

export default function Index() {
  const [newValue] = useState<any>(new Date());
  const [open, setOpen] = useState<boolean>(false);
  const onCancel = () => {
    setOpen(false);
  };
  const onClickInput = () => {
    setOpen(true);
  };

  const columns2: ColumnsType[] = [
    {
      title: 'Input',
      dataIndex: 'Input',
      valueType: 'FInputCustom',
      fieldProps: {},
    },
    {
      title: 'textarea',
      dataIndex: 'textarea',
      valueType: 'FInputCustom',
      fieldProps: {
        type: 'textarea',
      },
    },
  ];

  return (
    <>
      <Image
        width="100%"
        height={pxTransform(300)}
        src={`${OSS_URL}/static/images/assets/images/test.jpg`}
      />
      <Button
        type="primary"
        block
        className="home-btn"
        onClick={() => {
          Taro.redirectTo({
            url: '/pages/index/index',
          });
          // Taro.reLaunch({
          //   url: '/pages/index/index',
          // });
        }}
      >
        返回首页
      </Button>
      {/* <Cell title="选择">
        <Field
          readonly
          value={newValue}
          placeholder="请选择"
          border={false}
          inputAlign="right"
          onClickInput={onClickInput}
        />
        <Popup show={open} round position="bottom" zIndex={999} onClickOverlay={onCancel}>
          <DatetimePicker value={newValue} type="date" />
        </Popup>
      </Cell> */}

      <FFormCustom
        columns={columns2}
        onSubmit={(values: any) => {
          toast.success(values.Input + ' ' + values.textarea);
          console.log('===================');
          console.log(values);
          console.log('===================');
        }}
      />
    </>
  );
}
